package homework.test1;

import java.lang.reflect.Constructor;

public class Demo2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("homework.test1.Student");
        //1.获取class对象所有公共构造方法
        Constructor[] constructors = clazz.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }
        System.out.println("-----------------------------");
        //2.获取class对象所有构造方法
        Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
        System.out.println("-----------------------------");
        //3.获取class对象单个公共构造方法
        Constructor constructor = clazz.getConstructor();
        System.out.println(constructor);
        System.out.println("-----------------------------");
        //4.获取class对象单个构造方法
        Constructor declaredConstructor = clazz.getDeclaredConstructor(String.class);
        System.out.println(declaredConstructor);
    }
}
